﻿<Window x:Class="ThumbGen.ChooseMovieFromIMDb"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ThumbGen"
    SizeToContent="WidthAndHeight" WindowStyle="SingleBorderWindow" ResizeMode="CanResize" MinWidth="600"
     ShowInTaskbar="True" Title="Choose movie">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="Bool2VisibConverter"/>
    </Window.Resources>
    <Border Padding="1" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1" Background="White">
        <Border Padding="5" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1" Background="White"
                HorizontalAlignment="Stretch">
            <Grid MinWidth="100" MinHeight="30" HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <StackPanel Orientation="Vertical" x:Name="panelCollectorInfo">
                    <TextBlock Text="The preferred info collector" HorizontalAlignment="Center" FontWeight="Bold" Margin="0 5 0 0"/>
                    <TextBlock Margin="0" FontWeight="Bold" HorizontalAlignment="Center" Text="does not support search based on IMDB Id"/>
                    <TextBlock Text="Please select your movie from the list below:" HorizontalAlignment="Center" FontWeight="Bold" Margin="0 5 0 0"/>
                </StackPanel>
                
                <StackPanel Orientation="Vertical" x:Name="panelIMDBRefresh" Visibility="{Binding Path=IMDBMode, Converter={StaticResource Bool2VisibConverter}}">
                    <TextBlock Grid.Row="0" x:Name="DescriptionBlock" Margin="5" FontWeight="Bold" HorizontalAlignment="Center" 
                               Text="Choose the correct movie from the IMDB results list"/>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <TextBlock Text="or adjust the keywords " HorizontalAlignment="Center" VerticalAlignment="Center"/>

                        <TextBox x:Name="tbKeywords" Width="200" PreviewKeyDown="tbKeywords_PreviewKeyDown"/>
                        <TextBlock Text=" and press " VerticalAlignment="Center"/> 
                        <Button x:Name="btnRefresh" Content="Refresh list" Click="btnRefresh_Click"/>
                    </StackPanel>
                    <TextBlock FontSize="9" Margin="5" Text="Tip: Add the movie's year in brackets for better detection (eg. Spread (2009))" HorizontalAlignment="Center"/>
                </StackPanel>
                
                <ListBox Grid.Row="1" x:Name="MoviesBox" Margin="10" HorizontalAlignment="Stretch" MaxHeight="500"
                         IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" Grid.IsSharedSizeScope="True"
                         VirtualizingStackPanel.IsVirtualizing="False" MouseDoubleClick="MoviesBox_MouseDoubleClick">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Grid.Column="0" TextBlock.FontWeight="Bold" 
                                            Orientation="Horizontal" HorizontalAlignment="Left" ToolTip="Movie Name/Release Year"
                                            MaxWidth="500" Margin="5">
                                <TextBlock FontWeight="Normal" Text=" [ "/>
                                <TextBlock FontWeight="Normal" Text="{Binding IMDBID}"/>
                                
                                <Button VerticalAlignment="Center" Margin="5 0 0 0" Click="imdbInfoButton_Click" Tag="{Binding IMDBID}"
                                        ToolTip="Jump to IMDb.com and show movie details">
                                    <Button.Style>
                                        <Style>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding IMDBID}" Value="">
                                                    <Setter Property="Button.Visibility" Value="Collapsed"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                            <Setter Property="Button.Visibility" Value="Visible"/>
                                        </Style>
                                    </Button.Style>
                                    <Button.Template>
                                        <ControlTemplate>
                                            <Image Source="Images/Imdb_small.png" Width="16" Height="16" Cursor="Hand" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                                
                                <TextBlock FontWeight="Normal" Text=" ]" Margin="0 0 5 0" />
                                
                                <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
                                <TextBlock Text=" ( " />
                                <TextBlock Text="{Binding Year}" />
                                <TextBlock Text=" )" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="10" HorizontalAlignment="Center">
                    <Button x:Name="OkButton" ToolTip="Use the selected movie" FontWeight="Bold"
                            Content="Choose it!" MinWidth="75" Margin="3" IsDefault="False" Click="OkButton_Click"/>
                    <Button x:Name="Missing" ToolTip="The correct movie is not in the list skip selecting"
                            Content="Skip and search using initial keywords" MinWidth="75" Margin="3" Click="Missing_Click"/>
                    <Button x:Name="SkipButton" ToolTip="Skip processing current movie" FontWeight="Normal"
                            Content="Skip movie" MinWidth="75" Margin="3" Click="SkipButton_Click" Visibility="{Binding Path=IMDBMode, Converter={StaticResource Bool2VisibConverter}}"/>
                </StackPanel>
            </Grid>
        </Border>
    </Border>

</Window>